package com.itheima.udpqunliao;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

/*
udp 组播  (群聊) 发送端
 */
public class SendClient {

    public static void main(String[] args) throws IOException {
        //创建发送对象
        DatagramSocket ds = new DatagramSocket();
        //群发  地址群聊地址  组播地址范围 224.0.1.0~224.255.255.255
        InetAddress ip = InetAddress.getByName("224.0.1.0");
        int  port =10086;
        String s="我是发给群聊的消息";
        //创建数据对象
        DatagramPacket dp = new DatagramPacket(s.getBytes(), s.getBytes().length, ip, port);
        //发送
        ds.send(dp);


        //释放资源
        ds.close();



    }
}
